package com.fast.controller.jmeter;

import cn.hutool.core.thread.ThreadUtil;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author hujw
 * @since 2021/12/21
 */
@Api(tags = "JMeter测试")
@RestController
@RequestMapping("/jmeter")
public class TestController extends ApiController {

    @ApiOperation("测试查询列表")
    @GetMapping("/test1")
    public R test1() {
        List<Map> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Map<Integer, Object> hashmap = new HashMap<>();
            hashmap.put(i, "测试" + i);
            list.add(hashmap);
        }
        return success(list);
    }

    @ApiOperation("测试查询详情")
    @GetMapping("/test2")
    public R test2(Integer id) {
        Map<Integer, Object> hashmap = new HashMap<>();
        hashmap.put(id, "测试" + 1);
        return success(hashmap);
    }

    @ApiOperation("测试查询详情-延时1秒")
    @GetMapping("/test3")
    public R test3(Integer id) {
        ThreadUtil.sleep(1000);
        Map<Integer, Object> hashmap = new HashMap<>();
        hashmap.put(id, "测试" + 1);
        return success(hashmap);
    }
}
